<?php
class pager2{
    protected $_link;
    public function set_link($link){
        $this->_link = $link;
    }
    public function start(){
        if(isset($_GET['start'])){
            $start = $_GET['start'];
        }else{
            $start = 0;
        }
        return $start;
    }
    public function page($total,$limit){
        if(isset($_GET['pages'])){
            $page = $_GET['pages'];
        }else{
            $page = ceil($total/$limit);
        }
        return $page;
    }
    public function listpage($pages,$start,$limit){
        $list = "";
        if($pages > 1){
            $curpage = ($start/$limit) + 1;
            if($curpage != 1){
                $star = $start - $limit;
                $list.= "<a href='javascript:void(0)' name='$star' id='$pages' class='link prev' title='Prev'>Prev</a>";
            }
            for($i=1;$i<=$pages;$i++){
                if($curpage == $i){
                    $list.= "<span class='active'>".$i."</span>";
                }else{
                    $star = ($i - 1)*$limit;
                    $list.= "<a href='javascript:void(0)' name='$star' id='$pages' class='link'>".$i."</a>";
                }
            }
            if($curpage != $pages){
                $star = $start + $limit;
                $list.= "<a href='javascript:void(0)' name='$star' id='$pages' class='link next' title='Next'>Next</a>";
            }
            return $list;
        }
    }
    public function listpages($pages,$start,$limit,$type){
        $list = "";
        if($pages > 1){
            $curpage = ($start/$limit) + 1;
            if($curpage != 1){
                $star = $start - $limit;
                $list.= "<a href='javascript:void(0)' rel='$type' name='$star' id='$pages' class='links' title='Prev'>
					<img src='".base_url()."public/images/arrow_page_05.jpg' border='0'width='22' height='24' class='fl mgl3'/>
					</a>";
            }
            for($i=1;$i<=$pages;$i++){
                if($curpage == $i){
                    $list.= "<span class='active bder_rdus3 mgt1 fl apage mgl3'>".$i."</span>";
                }else{
                    $star = ($i - 1)*$limit;
                    $list.= "<a href='javascript:void(0)' rel='$type' name='$star' id='$pages' class='links bder_rdus3 mgt1 fl apage mgl3'>".$i."</a>";
                }
            }
            if($curpage != $pages){
                $star = $start + $limit;
                $list.= "<a href='javascript:void(0)' rel='$type' name='$star' id='$pages' class='links next' title='Next'>
					<img src='".base_url()."public/images/arrow_page_07.jpg' border='0' width='22' height='24' class='fl mgl3'/>
					</a>";
            }
            return $list;
        }
    }
}
?>
